package cn.richard.demo.ruleengine.web;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import cn.richard.demo.ruleengine.bean.ExTransDto;
import cn.richard.demo.ruleengine.config.RuleFireService;

@Controller
public class IndexCtrller {
	@Resource
	private RuleFireService ruleFireService;
	
	@RequestMapping("/exRule")
	public String exRule(Model model) {
		model.addAttribute("trans", new ExTransDto());
		return "exRule";
	}
	
	@PostMapping("/exRule")
	public String testRuleEx(ExTransDto dto, Model model) {
		ruleFireService.fire("trans", dto);
		model.addAttribute("trans", dto);
		
		return "exRule";
	}
}
